//package com.yuecai.modules.security.service;
//
//import org.springframework.security.authentication.AbstractAuthenticationToken;
//import org.springframework.security.core.GrantedAuthority;
//import org.springframework.security.core.SpringSecurityCoreVersion;
//
//import java.util.Collection;
//
//public class WeChatAuthenticationToken extends AbstractAuthenticationToken {
//    private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
//
//    private final Object principal;
//    private final String smsCode;
//    private final String cacheKey;
//
//    public WeChatAuthenticationToken(String mobile,String smsCode,String cacheKey) {
//        super(null);
//        this.principal = mobile;
//        this.smsCode = smsCode;
//        this.cacheKey = cacheKey;
//        this.setAuthenticated(false);
//    }
//
//    public WeChatAuthenticationToken(Object principal,String smsCode,String cacheKey,
//                                     Collection<? extends GrantedAuthority> authorities) {
//        super(authorities);
//        this.principal = principal;
//        this.smsCode = smsCode;
//        this.cacheKey = cacheKey;
//        // must use super, as we override
//        super.setAuthenticated(true);
//    }
//
//    @Override
//    public void setAuthenticated(boolean authenticated) {
//        if (authenticated) {
//            throw new IllegalArgumentException(
//                    "Cannot set this token to trusted - use constructor which takes a GrantedAuthority list instead");
//        }
//        super.setAuthenticated(false);
//    }
//
//    @Override
//    public Object getCredentials() {
//        return null;
//    }
//
//    @Override
//    public Object getPrincipal() {
//        return this.principal;
//    }
//
//    @Override
//    public void eraseCredentials() {
//        super.eraseCredentials();
//    }
//
//    public String getSmsCode() {
//        return smsCode;
//    }
//
//    public String getCacheKey() {
//        return cacheKey;
//    }
//}
